from random import randint

def my_func1():
    try:
        my_func2()
    except Exception as error :
        print("my_func1")
        print(error,type(error))
    # my_func2()


def my_func2():
    my_dict = {
        "a": 1,
        "b": 2
    }
    print(my_dict["c"])
    # try:
    #     if my_func3():
    #         my_dict["c"]
    # except Exception as error:
    #     print("my_func2")
    #     print(error)


# def my_func3():
#     # 如果是偶数就抛出异常
#     num = randint(0, 100)
#     if num % 2 == 0:
#         print('my_func3',num)
#         raise Exception("当前数字为偶数")
#     return True

# my_func1()

def my_func():
    try:
        my_dict = {
            "a": 1,
            "b": 2
        }
        print(my_dict["c"])
    except Exception as error:
        print(error, type(error))

def my_fun():
    try:
        print(10/0)
    except Exception as error:
        print(error,type(error))

my_func()
my_fun()
